﻿<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<!DOCTYPE html>
<head th:include="common/common_head::commonHeader('dalaoyang')"></head>

<body>
    <div id="wrapper">
        <div th:include="common/navigation :: navigation"></div>

        <div id="page-wrapper" >
            <div id="page-inner">
			 <div class="row">
                    <div class="col-md-12">
                        <h1 class="page-header">
                            标签列表<small></small>
                        </h1>
                    </div>
                </div> 
                 <!-- /. ROW  -->
               
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             所有标签
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline" role="grid">
                                <div class="row">
                                    <div class="col-sm-4">
                                        <div class="dataTables_filter"><label>标签名称:<input th:value="${tagName}" type="text" id="tagName" name="tagName" class="form-control input-sm" aria-controls="dataTables-example"></label></div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="dataTables_filter" style="float: right;">
                                            <label><button class="btn btn-primary btn-lg"  th:onclick="'javascript:search();'">搜索</button></label>
                                        </div>
                                    </div>
                                </div>
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>标签编号</th>
                                            <th>标签名称</th>
                                            <th  style="width:200px;">编辑</th>
                                        </tr>
                                    </thead>
                                    <tbody th:each="al,iterStat : ${tagList}">
                                        <tr class="odd gradeX">
                                            <td th:text="${al.tagId}"></td>
                                            <td th:text="${al.tagName}"></td>
                                            <td>
                                                <button  class="btn btn-primary btn-lg" th:onclick="'javascript:deleteLink('+${al.tagId}+');'">删除</button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                </div>
                                <div ><ul class="page" maxshowpageitem="5" pagelistcount="10"  id="page"></ul></div>

                            </div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
            </div>
                <!-- /. ROW  -->
            <footer><div th:include="common/footer :: footer"></div></footer>

        </div>
             <!-- /. PAGE INNER  -->
            </div>
    <div th:include="common/common_onload_js :: onLoadJs"></div>

    <script type="text/javascript"  th:inline="javascript">
        var totalCount =  [[${totalCount}]];
        var pageNumber =  [[${pageNumber}]];
        var urlPre =  [[${urlPre}]];
        var tagName = $('#tagName').val();

        var GG = {
            "kk":function(mm){
                window.location.href=getRootPath_dc() +"tagList?pageNumber="+mm+"&tagName="+tagName;
            }
        }
        $("#page").initPage(totalCount,pageNumber,GG.kk);

        function  search(){
            var tagName = $('#tagName').val();
            window.location.href=getRootPath_dc() +"tagList?tagName="+tagName;
        }

        function getRootPath_dc() {
            return window.location.protocol + '//' + window.location.host+"/";
        }

        function  deleteLink(tagId){
            if(confirm('确定删除吗，一经删除会删除所有文章下当前标签？')){
                $.ajax({
                    type: 'POST',
                    url: getRootPath_dc() +"deleteTag",
                    data: {tagId:tagId},
                    success: function(result){
                        alert('删除成功！');
                        search();
                    }
                });
            }
        }
    </script>

</body>
</html>
